<template>
  <section class="refundInfo">
    <el-collapse-transition>
      <div class="course-search separate">
        <div class="course-search-inner">
          <el-row>
            <el-col :span="12">
              <div class="search-inner-item">
                <div class="item-label">用户名称</div>
                <el-input
                  v-model.trim="listQuery.payAccountName"
                  style="width: 80%"
                  class="filter-item"
                  placeholder="请输入用户名称"
                />
              </div>
            </el-col>
            <el-col :span="12">
              <div class="search-inner-item">
                <div class="item-label">付款账户</div>
                <el-input
                  v-model.trim="listQuery.payAccount"
                  style="width: 80%"
                  class="filter-item"
                  placeholder="请输入完整的付款账户"
                />
              </div>
            </el-col>
          </el-row>
        </div>
        <div class="course-search-btn">
          <el-button class="filter-item" type="primary" @click="handleFilter">搜索</el-button>
          <el-button class="filter-item" type="primary" @click="handleReset">重置</el-button>
        </div>
      </div>
    </el-collapse-transition>
    <section class="main-buttons">
      <section class="main-buttons-title">
        <span>退款详情</span>
      </section>
      <section class="main-buttons-btns">
        <el-button style="margin-left: 10px" @click="exportFun">导出</el-button>
        <el-button style="margin-left: 10px" type="primary" @click="backFun">返回</el-button>
      </section>
    </section>

    <section class="main-table">
      <v-table
        :list="list"
        :tag="tableKey"
        :selection="false"
        :hover-arr="['balance']"
        :list-loading="listLoading"
        :filter-column="filtercolumn"
      />
      <pagination
        v-show="total > 0"
        :total="total"
        :page.sync="listQuery.page"
        :limit.sync="listQuery.limit"
        @pagination="getList"
      />
    </section>
  </section>
</template>
<script>
import {
  infoList,
  infoExportMask, infoExportNoMask
} from './../api'
import Pagination from '@/components/Pagination'
import VTable from '@/components/Table'
import elDragDialog from '@/directive/el-drag-dialog'
import CryptoJS from '@/utils/aesJiaJM'
import { exportSign } from '@/utils/fileImportOrExportSign'
import { exportCheck } from '@/utils/sensitiveInfoExportCheck'
export default {
  name: 'RefundInfo',
  components: {
    VTable,
    Pagination
  },
  directives: {
    elDragDialog
  },
  data() {
    return {
      listQuery: {
        page: 1,
        limit: 10,
        payAccountName: '',
        payAccount: ''
      },
      list: [],
      total: 0,
      listLoading: false,
      topInfo: {},
      backUrl: '',
      tableKey: 'refundmentDetail'
    }
  },
  beforeRouteEnter(to, from, next) {
    next(vm => {
      if (from.fullPath != '/') {
        sessionStorage.setItem('infoBack', from.fullPath)
      }
    })
  },
  created() {
    if (this.$route.query) {
      this.query = this.$route.query
      this.getList()
    } else {
      this.$message.error('页面参数错误')
      this.$router.back()
    }
  },
  methods: {
    backFun() {
      // if(sessionStorage.getItem("infoBack")){
      // 	this.$router.replace(sessionStorage.getItem("infoBack"))
      // }else{
      // 	this.$router.replace("/datacenter")
      // }
      this.$router.back()
    },
    exportFun() {
      var query = {

        page: this.listQuery.page,
        pageSize: this.listQuery.limit,
        recordId: this.$route.query.id,
        payAccountName: this.listQuery.payAccountName ? this.listQuery.payAccountName : '',
        payAccount: this.listQuery.payAccount ? this.listQuery.payAccount : ''
      }
      exportCheck('WELFARE_PAYMENT_STATISTICAL', this.$route.query.id, infoExportMask, infoExportNoMask, exportSign(query).obj, '退款详情.xlsx')
    },

    filtercolumn(scope, item) {
      if (item == 'payAccount') {
        return CryptoJS.$aesJieM(scope.row[item])
      } else {
        return scope.row[item]
      }
    },
    handleReset() {
      this.listQuery.page = 1
      this.listQuery.payAccountName = ''
      this.listQuery.payAccount = ''
      this.getList()
    },

    handleFilter() {
      this.listQuery.page = 1
      this.getList()
      this.getInfo()
    },

    getList(obj) {
      this.listLoading = true
      var query = {
        page: this.listQuery.page,
        pageSize: this.listQuery.limit,
        recordId: this.$route.query.id,
        payAccountName: this.listQuery.payAccountName ? this.listQuery.payAccountName : '',
        payAccount: this.listQuery.payAccount ? CryptoJS.$aesJiaM(this.listQuery.payAccount) : ''
      }
      return new Promise((resolve, reject) => {
        infoList(query).then(response => {
          this.list = response.data.data.rows || []
          this.total = response.data.data.total
          this.listLoading = false
        }).catch(error => {
          reject(error)
          this.listLoading = false
        })
      })
    }
  }
}
</script>
<style lang="scss">
	@import '@/styles/mixin.scss';
	$dark_gray: #bfced6;

	.refundInfo {
		padding: 10px;

		.el-dialog .el-dialog__body {
			max-height: 73vh !important;
		}

		.line {
			text-align: center;
		}

		.el-card {
			margin-bottom: 10px;

			.current-position-name {
				font-size: 18px;
				font-weight: bold;
				margin-bottom: 10px;
			}
		}

		.course-search {
			background-color: #fff;
			padding: 0 10px;

			.svg-container {
				padding: 0 5px 0 10px;
				color: $dark_gray;
				vertical-align: middle;
				display: inline-block;

				&_login {
					font-size: 20px;
				}
			}

			.search-input {
				width: 60%;
				position: relative;

				&:after {
					content: "";
					position: absolute;
					left: -25px;
					right: 0;
					bottom: 8px;
					height: 1px;
					background: rgba(226, 227, 232, 1);
				}

				input {
					outline: none;
					background: transparent;
					border: none;
					outline: medium;
					padding: 0;

					&:focus {
						outline: none;
						background-color: transparent;
					}
				}
			}

			.course-search-btn {
				display: inline-block;
				float: right;

				.el-button.is-round {
					padding: 10px 30px;
					margin-right: 34px;
				}

				.course-search-more {
					font-size: 14px;
					font-weight: 500;
					@include font-color($mainColor);
					cursor: pointer;
					margin-left: 10px;
				}
			}

			&.merge {
				height: 50px;
				line-height: 50px;
			}

			&.separate {
				.course-search-inner {
					padding-top: 10px;

					// .el-input--medium .el-input__inner {
					// 	padding-left: 30px !important;
					// }
					.search-inner-item {
						.item-label {
							height: 30px;
							line-height: 30px;
							font-size: 14px;
							color: #a6a6a6;
							font-weight: 400;
						}

						.el-input {
							position: relative;

							.el-input__inner {
								border: none;
								padding: 0;
							}

							&:after {
								content: "";
								height: 1px;
								background-color: #e2e3e8;
								position: absolute;
								left: 0;
								right: 0;
								bottom: 0;
							}
						}
					}
				}

				.course-search-btn {
					text-align: center;
					display: block;
					float: none;
					height: 56px;
					line-height: 56px;
				}
			}
		}

		.main-buttons {
			display: flex;
			line-height: 36px;
			margin: 10px 0;

			.main-buttons-title {
				flex: 1;
				height: 36px;
				line-height: 36px;
				font-size: 16px;
				font-weight: bold;
				color: rgba(51, 51, 51, 1);

				.num {
					@include font-color($mainColor);
				}
			}
		}
	}
</style>
